<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>我的配送地址簿</title>
    <link rel="stylesheet" href="__PUBLIC__/Home/css/personCenter/personAddr.css">
    <link href="__PUBLIC__/Home/css/personCenter/city-picker.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <div class="myAddr">
      <!-- 标题 -->
      <p class="mytitle">我的配送地址簿</p>
      <!-- 表格table的div -->
      <div class="mybox">
        <p>已添加的地址</p>
        <table class="mytable">
            <tr style="height:42px;">
              <th class="name">收货人姓名</th>
              <th class="area">所在地区</th>
              <th class="street">街道地址</th>
              <th class="postcode">邮编</th>
              <th class="phone">电话/手机</th>
              <th class="operation">操作</th>
            </tr>
            <foreach name="list" item="val">
            <tr style="height:48px;">
	            <td class="name">{$val.receiver}</td>
	            <td class="area">{$val.province}-{$val.city}-{$val.country}</td>
	            <td class="street">{$val.addr_detail}</td>
	            <td class="postcode">{$val.postcode}</td>
	            <td class="phone">{$val.phone}</td>

	            <td class="operation" style="padding:0">
	                    <!-- <a href="__CONTROLLER__/personAddrSave?addr_id={$val.addr_id}">修改</a> -->
	                    <a href="{:U('personCenter/personAddrSave',array('addr_id'=>$val['addr_id'],'user_id'=>$val['user_id']))}">修改</a>
	                    <em>|</em>
	                    <a href="{:U('personCenter/personAddrDelete',array('addr_id'=>$val['addr_id'],'user_id'=>$val['user_id']))}">删除</a>
                      <if condition="$val.status eq '1'">
                        <span>默认</span>
                      </if>
                      <if condition="$val.status neq 1">
                         <a href="{:U('personCenter/defaultAddr',array('addr_id'=>$val['addr_id'],'user_id'=>$val['user_id']))}">设为默认</a>
                      </if>
	            </td>
	         </tr>
         </foreach>
        </table>
      </div>
      <!-- 表格table完 -->
      <!-- 新增配送地址表单开始 -->
      <p class="mytitle">新增配送地址<span>请填写以下信息*为必填项</span></p>
      <form class="" action="{:U('personCenter/personAddrAdd')}" method="post">
        <input type="hidden" name="user_id" value="{$user_id}">
        <label for="realname" class="mylabel">*请填写收货人真实姓名</label>
        <div class="mydiv">
          <input type="text" name="receiver" class="myinput" style="width:140px;" id="receiver">
          <span id="receivertips" style="color:red"></span>
        </div>
        <label for="realplace" class="mylabel">*所属地区</label>
        <div class="mydiv" style="padding:0;height:47px;width:500px;">
            <!-- 全国三级联动js开始 -->
            <div id="distpicker" style="width:40px;">
              <!-- <div class="form-group"> -->
                <div style="position: relative;">
                  <input id="city-picker3" name="area" class="form-control" readonly type="text" data-toggle="city-picker">
                </div>
              <!-- </div> -->
            </div>
            <!-- 全国三级联动js结束 -->
        </div>

        <!-- 详细街道地址 -->
        <label for="addr_detai" class="mylabel">*街道地址（不需要重复填写省/市/区）</label>
        <div class="mydiv" >
          <input type="text" name="addr_detail" class="myinput" style="width:300px;" id="addr_detail">
          <span id="addr_detailtips" style="color:red"></span>
        </div>
        <!-- 邮政编码 -->
        <label for="postcode" class="mylabel">*邮政编码</label>
        <div class="mydiv">
          <input type="text" name="postcode" class="myinput" style="width:140px;" id="postcode">
          <span id="postcodetips" style="color:red"></span>
        </div>
        <!-- 电话号码 -->
        <label for="phone" class="mylabel">*手机号码</label>
        <div class="mydiv">
          <input type="text" name="phone" class="myinput" style="width:300px;" id="phone">
          <span id="phonetips" style="color:red"></span>
        </div>
        <!-- 设置默认地址的隐藏域 -->
        <input type="hidden" name="status" value="0">
        <div class="mydiv" style="margin-top:30px;">
          <input type="submit" value="确定" id="submit">
        </div>
      </form>
    </div>
  </body>
  <!-- 导入地区的三级联动开始 -->
  <script src="__PUBLIC__/Home/js/personCenter/jquery.js"></script>
  <script src="__PUBLIC__/Home/js/personCenter/city-picker.data.js"></script>
  <script src="__PUBLIC__/Home/js/personCenter/city-picker.js"></script>
  <script src="__PUBLIC__/Home/js/personCenter/main.js"></script>
  <!-- 地区三级联动结束 -->
  <script type="text/javascript">
    $('#checkbox').click(
      function(){
        if($(this).attr('sign')=='false'){
        $(this).css('background-color','#027BBB');
        $(this).attr('sign','true');
        $("input[name='status']").val(1);
      }else {
        $(this).css('background-color','#FFF');
        $(this).attr('sign','false');
        $("input[name='status']").val(0);
      }
    });
    window.onload = function(){
      var mywidth=document.body.scrollHeight;
      // console.log(mywidth);
      top.document.getElementById('show').innerHTML = mywidth;
      top.back();
    };

    // js页面验证提交的信息
    $(function(){
      var k1 = false;
      var k2 = false;
      var k3 = false;
      var k4 = false;
      $('#submit').on('click',function(){
        //1.验证收货人真实姓名
        var reg1= /^[\u4e00-\u9fa5]{2,12}$/;
            if(!reg1.test($("#receiver").val())){
                $("#receivertips").html("收货人姓名格式错误");
            }else{
                $("#receivertips").html("");
                k1=true;
            }
        // 2.验证邮政编码
        var reg2=/^\d{6}$/;
            if(!reg2.test($("#postcode").val())){
                $("#postcodetips").html("邮政编码输入错误");
            }else{
                $("#postcodetips").html("");
                k2=true;
            }
        /*3 .手机号验证*/
        var reg3= /^1[35689]\d{9}$/;
            if(!reg3.test($("#phone").val())){
                $("#phonetips").html("请输入11位手机号码");
            }else{
                $("#phonetips").html("");
                k3=true;
            }
          /*4 .详细地址的验证*/
            if($("#addr_detail").val()!=''&& $(".title").html()!=''){
              $("#addr_detailtips").html("");
              k4=true;
            }else{
              $("#addr_detailtips").html("请输入省份或详细地址");

        if(k1 == true && k2 == true && k3 == true && k4 == true){

        }else{
          return false;
        }
      });
    });
  </script>
</html>
